package com.shujia

import scala.collection.mutable

object Demo20Set {
  def main(args: Array[String]): Unit = {

    /**
      * set 集合     唯一,无序
      *
      */

    val ints: Set[Int] = Set(1, 2, 3, 4, 5, 1)

    println(ints)


    val set1: Set[Int] = Set(1, 2, 3, 4, 5, 6, 7)
    val set2: Set[Int] = Set(4, 5, 6, 7, 8, 9, 10)


    println(set1 & set2) //交集
    println(set1 | set2) //并集
    println(set1 &~ set2) //差集


    val set4: mutable.HashSet[Int] = new mutable.HashSet[Int]()

    set4 += 1
    set4 += 2
    set4 += 3
    set4 += 4

    println(set4)


  }

}
